🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / androidApp / src / google / kotlin / org / meshtastic / app / map / offline / pmtiles / PmTilesDailyBuild.kt
Displaying Raw • Download
androidApp/src/google/kotlin/org/meshtastic/app/map/offline/pmtiles/PmTilesDailyBuild.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 3.05 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.app.map.offline.pmtiles
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787java.net.HttpURLConnection
Tff7b72import T7ee787java.net.URL
Tff7b72import T7ee787java.time.LocalDate
Tff7b72import T7ee787java.time.ZoneOffset
Tff7b72import T7ee787java.time.format.DateTimeFormatter
T8b949e/**
* Resolves the most recent Protomaps daily basemap build, the same public dataset the sibling iOS app slices its own
* offline regions from (`Meshtastic/Helpers/Map/PMTilesExtractor.swift`).
*
* There is no "latest" alias — a build is published (usually) once a day at a date-stamped URL, and a given date's file
* can be briefly missing around the daily publish window — so this probes backward a bounded number of days for the
* first one that responds. A HEAD request only; the multi-gigabyte body is never touched here, only later, one tile's
* worth of bytes at a time, by [ch.poole.geo.pmtiles.Reader] against whichever URL this resolves to.
*/
Tff7b72internal Tff7b72object T56d364PmTilesDailyBuild Tb4b4b4{
Tff7b72private Tff7b72val Te6edf3LOG Tff7b72= Te6edf3LoggerTb4b4b4.Te6edf3withTagTb4b4b4(Ta5d6ff"Ta5d6ffPmTilesDailyBuildTa5d6ff"Tb4b4b4)
Tff7b72private Tff7b72const Tff7b72val Te6edf3BASE_URL Tff7b72= Ta5d6ff"Ta5d6ffhttps://build.protomaps.comTa5d6ff"
Tff7b72private Tff7b72const Tff7b72val Te6edf3MAX_DAYS_BACK Tff7b72= T79c0ff1T79c0ff6
Tff7b72private Tff7b72const Tff7b72val Te6edf3HEAD_TIMEOUT_MS Tff7b72= T79c0ff8Te6edf3_000
Tff7b72private Tff7b72val Te6edf3DATE_FORMAT Tff7b72= Te6edf3DateTimeFormatterTb4b4b4.Te6edf3ofPatternTb4b4b4(Ta5d6ff"Ta5d6ffyyyyMMddTa5d6ff"Tb4b4b4)
T8b949e/** The newest daily build URL that actually exists, or null if none of the last [MAX_DAYS_BACK] days do. */
Tff7b72fun Td2a8ffresolveLatestUrlTb4b4b4(Te6edf3todayTb4b4b4: Te6edf3LocalDate Tff7b72= Te6edf3LocalDateTb4b4b4.Te6edf3nowTb4b4b4(Te6edf3ZoneOffsetTb4b4b4.Te6edf3UTCTb4b4b4)Tb4b4b4)Tb4b4b4: Te6edf3URL? Tb4b4b4{
Tff7b72for Tb4b4b4(Te6edf3daysBack Tff7b72in T79c0ff0 Te6edf3until Te6edf3MAX_DAYS_BACKTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3candidate Tff7b72= Te6edf3urlForTb4b4b4(Te6edf3todayTb4b4b4.Te6edf3minusDaysTb4b4b4(Te6edf3daysBackTb4b4b4.Te6edf3toLongTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3existsTb4b4b4(Te6edf3candidateTb4b4b4)Tb4b4b4) Tff7b72return Te6edf3candidate
Tb4b4b4}
Te6edf3LOGTb4b4b4.Te6edf3w Tb4b4b4{ Ta5d6ff"Ta5d6ffNo Protomaps daily build found in the last Tffd700$Te6edf3MAX_DAYS_BACKTa5d6ff daysTa5d6ff" Tb4b4b4}
Tff7b72return Tff7b72null
Tb4b4b4}
Tff7b72private Tff7b72fun Td2a8ffurlForTb4b4b4(Te6edf3dateTb4b4b4: Te6edf3LocalDateTb4b4b4)Tb4b4b4: Te6edf3URL Tff7b72= Te6edf3URLTb4b4b4(Ta5d6ff"Tffd700$Te6edf3BASE_URLTa5d6ff/Tffd700${Te6edf3DATE_FORMATTb4b4b4.Te6edf3formatTb4b4b4(Te6edf3dateTb4b4b4)Tffd700}Ta5d6ff.pmtilesTa5d6ff"Tb4b4b4)
Tff7b72private Tff7b72fun Td2a8ffexistsTb4b4b4(Te6edf3urlTb4b4b4: Te6edf3URLTb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Tff7b72val Te6edf3connection Tff7b72= Te6edf3urlTb4b4b4.Te6edf3openConnectionTb4b4b4(Tb4b4b4) Tff7b72as? Te6edf3HttpURLConnection Tff7b72?: Tff7b72return Tff7b72false
Tff7b72return Tff7b72try Tb4b4b4{
Te6edf3connectionTb4b4b4.Te6edf3requestMethod Tff7b72= Ta5d6ff"Ta5d6ffHEADTa5d6ff"
Te6edf3connectionTb4b4b4.Te6edf3connectTimeout Tff7b72= Te6edf3HEAD_TIMEOUT_MS
Te6edf3connectionTb4b4b4.Te6edf3readTimeout Tff7b72= Te6edf3HEAD_TIMEOUT_MS
Te6edf3connectionTb4b4b4.Te6edf3responseCode Tff7b72=Tff7b72= Te6edf3HttpURLConnectionTb4b4b4.Te6edf3HTTP_OK
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3eTb4b4b4: Te6edf3javaTb4b4b4.Te6edf3ioTb4b4b4.Te6edf3IOExceptionTb4b4b4) Tb4b4b4{
Te6edf3LOGTb4b4b4.Te6edf3dTb4b4b4(Te6edf3eTb4b4b4) Tb4b4b4{ Ta5d6ff"Ta5d6ffProbe failed for Tffd700$Te6edf3urlTa5d6ff" Tb4b4b4}
Tff7b72false
Tb4b4b4} Tff7b72finally Tb4b4b4{
Te6edf3connectionTb4b4b4.Te6edf3disconnectTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.2 - Generated in 0.09s